package cn.fbs.util;

import com.github.pagehelper.PageInfo;

import java.util.List;


/**
 * @program: springbootdemo
 * <li> @description: 分页结果封装类
 * @author: wxk
 * @create: 2020-12-22 09:11
 **/
public class PageResult<T> {
    private Long total; //总条数
    private Integer totalPage;//总页数
    private List<T> items;//当前页数据

    public PageResult(){

    }
    
    public PageResult(List<T> items){
        PageInfo<T> pageInfo = new PageInfo<T>(items);
        this.total = pageInfo.getTotal();
        this.totalPage = pageInfo.getPages();
        this.items = items;
    }

    public PageResult(Long total, List<T> items){
        this.total = total;
        this.items = items;
    }

    public PageResult(Long total, Integer totalPage, List<T> items){
        this.total = total;
        this.totalPage = totalPage;
        this.items = items;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Integer getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(Integer totalPage) {
        this.totalPage = totalPage;
    }

    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }
}
